package com.zhipu.hydration.ui.system;

import android.os.Bundle;

import com.blankj.utilcode.util.ActivityUtils;
import com.zhipu.hydration.R;
import com.zhipu.hydration.databinding.ActivitySystemBinding;
import com.zhipu.hydration.ui.BaseActivity;
import com.zhipu.hydration.ui.data.DataActivity;
import com.zhipu.hydration.ui.start.StartActivity;

import in.xiandan.countdowntimer.CountDownTimerSupport;
import in.xiandan.countdowntimer.OnCountDownTimerListener;

/**
 * 系统初始化
 */
public class SystemActivity extends BaseActivity<ActivitySystemBinding> {

    private CountDownTimerSupport mTimernumber = new CountDownTimerSupport(10000, 1000);
    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_system;
    }


    @Override
    public void initView() {
        super.initView();
        mTimernumber.setOnCountDownTimerListener(new OnCountDownTimerListener() {
            @Override
            public void onTick(long millisUntilFinished) {
                switch ((int)(millisUntilFinished / 1000)){
                    case 10:
                        binding.bar.setProgress(10);
                        break;
                    case 9:
                        binding.bar.setProgress(20);
                        break;
                    case 8:
                        binding.bar.setProgress(30);
                        break;
                    case 7:
                        binding.bar.setProgress(40);
                        break;
                    case 6:
                        binding.bar.setProgress(50);
                        break;
                    case 5:
                        binding.bar.setProgress(60);
                        break;
                    case 4:
                        binding.bar.setProgress(70);
                        break;
                    case 3:
                        binding.bar.setProgress(80);
                        break;
                    case 2:
                        binding.bar.setProgress(90);
                        break;
                    case 1:
                        binding.bar.setProgress(100);
                        ActivityUtils.startActivity(DataActivity.class);
                        ActivityUtils.finishActivity(SystemActivity.class);
                        break;
                }
            }

            @Override
            public void onFinish() {
            }

            @Override
            public void onCancel() {

            }
        });
        if(null != mTimernumber){
            //倒计时开始
            mTimernumber.reset();
            mTimernumber.start();
        }


    }
}
